import { CellRenderer } from "../../../../../fl/controls/listClasses/CellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { SPublicMiniPlayer } from "../../../../../Message/Public/SPublicMiniPlayer";
import { AvatarInfo } from "../../../resource/info/AvatarInfo";
import { AvatarType } from "../../../resource/info/AvatarType";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { ColorConfig } from "../../../resource/ColorConfig";
import { PlayerOpRegister } from "../../common/menu/PlayerOpRegister";
import { PlayerMiniInfo } from "../../../model/PlayerMiniInfo";
import { ImageInfo } from "../../../../../com/gengine/resource/info/ImageInfo";
import { GLabel } from "../../../../../com/mui/controls/GLabel";
//class OneKeyFriendsHeadCellrenderer
    
    export  class OneKeyFriendsHeadCellrenderer extends CellRenderer
    {
        constructor()
        {
            super();
            this.initStyle();
            this.createChildren();
            this.mouseChildren = true;
            return;
        }

        /* internal  */initStyle(): void
        {
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("downSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("overSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedOverSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedUpSkin", new Object /* flash.display.Bitmap */());
            return;
        }

        /* internal  */createChildren(): void
        {
            this._clickSp = new Object /* flash.display.Sprite */();
            this.addChild(this._clickSp);
            this._head = new Object /* flash.display.Bitmap */();
            this._head.x = 21;
            this._head.y = 21;
            this._clickSp.addChild(this._head);
            this._campBm = new Object /* flash.display.Bitmap */();
            this._campBm.y = 65;
            this._clickSp.addChild(this._campBm);
            this._nameLabel = ObjCreate.createLabel("", 0, 90, 95, 20, flash.text.TextFormatAlign.CENTER, this._clickSp, true, 16776960);
            this._nameLabel.drawNow();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            var loc1=data as SPublicMiniPlayer;
            if (loc1) 
            {
                AvatarInfo.getAvatar(loc1.camp, loc1.sex, AvatarType.SMALL, this.onAvatarLoaded, loc1.avatarId);
                this._campBm.bitmapData = GlobalClass.getBitmapData(AvatarInfo.getPicNameByCamp(loc1.camp));
                this._nameLabel.htmlText = HTMLUtil.addColor("<u>" + loc1.name + "</u>", ColorConfig.instance.getCampColor(loc1.camp).color);
                PlayerOpRegister.Register(this._clickSp, new PlayerMiniInfo(loc1));
            }
            else 
            {
                this._head.bitmapData = null;
                this._campBm.bitmapData = null;
                this._nameLabel.htmlText = "";
                PlayerOpRegister.UnRegister(this._clickSp);
            }
            return;
        }

        /* internal  */onAvatarLoaded(arg1: ImageInfo): void
        {
            this._head.bitmapData = arg1.bitmapData;
            return;
        }

        /* internal */ /* var */_clickSp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_head: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_campBm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_nameLabel: GLabel;
    }
